<template>
  <div>
    <el-form :inline="true" :model="model"  label-width="100px" class="demo-ruleForm">
      <el-form-item label="计划治疗日期" prop="planTreatmentDate">
        <el-date-picker v-model="model.planTreatmentDate" type="date" placeholder="选择治疗时间" class="width220" value-format="yyyy-MM-dd" value="yyyy-MM-dd" :disabled="type==='watch'"/>
      </el-form-item>
      <el-form-item label="治疗类型" prop="treatmentType">
        <el-select v-model="model.treatmentType" placeholder="请选择" class="width220" :disabled="type==='watch'" @change="changeTreatmentType">
          <el-option v-for="item in typeList" :key="item.id" :label="item.name" :value="item.id"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="治疗预计耗时" prop="treatmentUseTime">
        <el-input v-model="model.treatmentUseTime"  class="width220" disabled><template slot="append" >分钟</template></el-input>
      </el-form-item>
      <!-- <el-form-item label="治疗次数" prop="treatmentTimes">
         <el-input-number v-model="model.treatmentTimes" controls-position="right" :min="1" class="width220" :disabled="type==='watch'"></el-input-number>
      </el-form-item> -->
      <el-form-item label="备注" prop="remark" class="form-item-block">
         <el-input type="textarea" :rows="2" placeholder="请输入备注" v-model="model.remark" class="width520" :disabled="type==='watch'"/>
       </el-form-item>
       <el-form-item  class="form-item-block text-center">
          <el-button type="primary"  @click="submit" v-if="type!=='watch'">确定</el-button>
       </el-form-item>
    </el-form>
  </div>
</template>
<script>
import {planTreatment} from "plugins/axios/inquiryRecord.js"
export default {
  props:{
    typeList:{
      type:Array,
      default(){
        return []
      }
    },
    providerId:{
      type:[String,Number]
    },
    type:{
      type:[String],
      default:'insert'
    },
    model:{
      type:Object,
      default(){
        return {}
      }
    }
  },
  data(){
    return{}
  },
  created(){},
  mounted(){
  },
  watch:{},
  computed:{},
  methods:{
    submit(){
      let self = this,
      postData={
        ...this.model
      }
      self.type==='insert'?postData.providerNo=self.providerId:'';
      planTreatment(self.type,postData).then(res=>{
        self.$message.success(`${self.type==='insert'?'新增':'修改'}成功`)
        self.$emit('submitSuccess')
        self.model ={}
      })
    },
    changeTreatmentType(val){
      let self= this;
      self.typeList.forEach(item=>{
        if(val===item.id){
          console.log(item.time)
          self.model.treatmentUseTime=item.time;
        }
      })
    }
  }
}
</script>
<style scoped>
</style>